program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  pelement=^element;
  element=record
    value:integer;
    next:pelement;
  end;
var
  a: element;
  fin: textFile;
  n, x, i, t: integer;
  head: pelement;
function DeleteEnd(var head: pelement):integer;
var
  current: pelement;
begin
  if (head<>nil) then
  begin
    current:=head;
    while (current^.next<>nil) do
      current:=current^.next;
    DeleteEnd:=current^.value;
    dispose(current);
  end;
end;
procedure AddToBegin(var head: pelement; num: integer);
var
  tmp: pelement;
begin
  tmp:=head;
  new (head);
  head^.next:=tmp;
  head^.value:=num;
end;
begin
  assignFile(fin,'input.txt');
  reset(fin);
  readln(fin,n);
  new(head);
  for i:=1 to n do
  begin
    readln(fin,x);
    AddToBegin(head,x);
  end;
  for i:=1 to n do
  begin
    t:=DeleteEnd(head);
    writeln(t);
  end;
  closeFile(fin);
  readln;
end.
